<template>
  <div>
    <h3>搜索页面:{{ $route.query }}</h3>
  </div>
</template>

<script>
export default {
  name: 'Search',
  watch: {
    '$route.query': {
      handler () {
        this.$store.dispatch("product/postSearchListAsync", this.$route.query)
      },
      immediate: true
    }
  },
  // async beforeRouteUpdate (to, from, next) {
  //   await this.$store.dispatch('product/postSearchListAsync', {
  //     keyword: to.query.keyword
  //   })
  // },
  // mounted () {
  //   this.$store.dispatch('product/postSearchListAsync', {
  //     keyword: this.$route.query.keyword
  //   })
  // }
}
</script>

<style lang="less" scoped>
h3 {
  background: pink;
  padding: 50px;
  font-size: 50px;
}
</style>